# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/13 19:09
# @Author   : Robot-Zsj
"""
description:

i:
7
8
4
6
3
1
6
7
10

o:
3
"""
n = int(input())

gems = []
for _ in range(n):
    gems.append(int(input()))

v = int(input())


def getResult():
    ans = 0

    l = 0
    r = 0

    window_sum = 0

    while r < n:
        window_sum += gems[r]

        if window_sum <= v:
            r += 1
        else:
            ans = max(ans, r - l)

            flag = False

            while l < r:
                window_sum -= gems[l]
                l += 1

                if window_sum <= v:
                    r += 1
                    flag = True
                    break

            if flag:
                continue

            r += 1
            l = r
            window_sum = 0

    if window_sum <= v:
        ans = max(ans, r - l)

    return ans


print(getResult())
